<script setup>
import { ref, onMounted } from 'vue';
import {queryPageApi} from '@/api/log';

const logList=ref([]);

 // 分页
 const currentPage = ref(1)
const pageSize = ref(10)
const background = ref(true)
const total=ref(0);

// 每页展示记录数变化
const handleSizeChange = (val) => {
  search();
}

// 页码变化时触发
const handleCurrentChange = (val) => {
  search();
}

const search=async()=>{
  const result=await queryPageApi(currentPage.value,pageSize.value);
  if (result.code) {
    logList.value=result.data.rows;
    total.value=result.data.total;
  }
}

onMounted(()=>{
  search();
})
</script>

<template>
  <h1>日志管理</h1>
  <div class="container">
    
   <!-- 展示表格 -->
   <div class="container">
      <el-table :data="logList" border style="width: 100%" >
      <el-table-column prop="operateEmpName" width="80" label="操作人" align="center"/>
      <el-table-column prop="operateTime" label="操作时间" width="200" align="center"/>
      <el-table-column prop="className"  label="类名" width="350" align="center" />
      <el-table-column prop="methodName"  label="方法名" width="80" align="center"/>
      <el-table-column prop="costTime" label="操作耗时" width="80" align="center"/>
      <el-table-column prop="methodParams" label="请求参数" width="900" align="center" />
      <el-table-column prop="returnValue" label="返回值" width="80" align="center"/>
    </el-table>
   </div><br>
   
  <!-- 分页条 -->
  <div class="container">
    <el-pagination
      v-model:current-page="currentPage"
      v-model:page-size="pageSize"
      :page-sizes="[5,10, 20, 30, 50]"
      :background="background"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
  </div>
</template>

<style scoped>

</style>